import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

class ToastUtils {
    
    static showMsg(String strMsg) {
    
        Fluttertoast.showToast(
            msg: strMsg,
            toastLength: Toast.LENGTH_SHORT,
            gravity: ToastGravity.CENTER,
            timeInSecForIos:1,
        );
    }

    static showAlertDialog(BuildContext context, String msg) {
        showDialog(
            context: context,
            barrierDismissible: false, // user must tap button!
            builder: (BuildContext ctx) {
                return new AlertDialog(
                    title: new Text('提示'),
                    content: new Text(msg),
                    actions: <Widget>[
                        new FlatButton(
                            child: new Text(
                                '确定',
                                style: new TextStyle(color: Colors.blue),
                            ),
                            onPressed: () {
                                Navigator.of(ctx).pop();
                            },
                        )
                    ],
                );
            });
    }

    static showConfirmDialog(BuildContext context, String msg, Function enterFn) {
        showDialog(
            context: context,
            barrierDismissible: false, // user must tap button!
            builder: (BuildContext ctx) {
                return new AlertDialog(
                    title: new Text('确认'),
                    content: new Text(msg),
                    actions: <Widget>[
                        new FlatButton(
                            child: new Text(
                                '取消',
                                style: new TextStyle(color: Colors.grey),
                            ),
                            onPressed: () {
                                Navigator.of(ctx).pop();
                            },
                        ),
                        new FlatButton(
                            child: new Text(
                                '确定',
                                style: new TextStyle(color: Colors.blue),
                            ),
                            onPressed: () {
                                enterFn();
                                Navigator.of(ctx).pop();
                            },
                        )
                    ],
                );
            });
    }

    
}